home *** CD-ROM | disk | FTP | other *** search
/ Hackers Magazine 57 / CdHackersMagazineNr57.iso / Software / Programming / nsis-2.46-setup.exe / Contrib / Modern UI 2 / Interface.nsh < prev    next >
Encoding:
Text File  |  2008-04-18  |  7.5 KB  |  305 lines

  1. /*
  2.  
  3. NSIS Modern User Interface
  4. Interface code for all pages
  5.  
  6. */
  7.  
  8. ;--------------------------------
  9. ;Variables
  10.  
  11. Var mui.Header.Text
  12. Var mui.Header.Text.Font
  13. Var mui.Header.SubText
  14. Var mui.Header.Background
  15. Var mui.Header.Image
  16.  
  17. Var mui.Branding.Text
  18. Var mui.Branding.Background
  19.  
  20. Var mui.Line.Standard
  21. Var mui.Line.FullWindow
  22.  
  23. Var mui.Button.Next
  24. Var mui.Button.Cancel
  25. Var mui.Button.Back
  26.  
  27.  
  28. ;--------------------------------
  29. ;General interface settings
  30.  
  31. !macro MUI_INTERFACE
  32.  
  33.   !ifndef MUI_INTERFACE
  34.  
  35.     !define MUI_INTERFACE
  36.  
  37.     ;These values are set after the interface settings in the script,
  38.     ;so the script itself can override all values.
  39.  
  40.     ;Default interface settings in nsisconf.nsh
  41.     !ifdef MUI_INSERT_NSISCONF
  42.       !insertmacro MUI_NSISCONF
  43.     !endif
  44.  
  45.     ;Default interface settings
  46.     !insertmacro MUI_DEFAULT MUI_UI "${NSISDIR}\Contrib\UIs\modern.exe"
  47.     !insertmacro MUI_DEFAULT MUI_UI_HEADERIMAGE "${NSISDIR}\Contrib\UIs\modern_headerbmp.exe"
  48.     !insertmacro MUI_DEFAULT MUI_UI_HEADERIMAGE_RIGHT "${NSISDIR}\Contrib\UIs\modern_headerbmpr.exe"
  49.     !insertmacro MUI_DEFAULT MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\modern-install.ico"
  50.     !insertmacro MUI_DEFAULT MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\modern-uninstall.ico"
  51.     !insertmacro MUI_DEFAULT MUI_BGCOLOR "FFFFFF"
  52.  
  53.     ;Default header images
  54.     !ifdef MUI_HEADERIMAGE
  55.  
  56.       !insertmacro MUI_DEFAULT MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\nsis.bmp"
  57.  
  58.       !ifndef MUI_HEADERIMAGE_UNBITMAP
  59.         !define MUI_HEADERIMAGE_UNBITMAP "${MUI_HEADERIMAGE_BITMAP}"
  60.         !ifdef MUI_HEADERIMAGE_BITMAP_NOSTRETCH
  61.           !insertmacro MUI_SET MUI_HEADERIMAGE_UNBITMAP_NOSTRETCH ""
  62.         !endif
  63.       !endif
  64.  
  65.       !ifdef MUI_HEADERIMAGE_BITMAP_RTL
  66.         !ifndef MUI_HEADERIMAGE_UNBITMAP_RTL
  67.           !define MUI_HEADERIMAGE_UNBITMAP_RTL "${MUI_HEADERIMAGE_BITMAP_RTL}"
  68.           !ifdef MUI_HEADERIMAGE_BITMAP_RTL_NOSTRETCH
  69.             !insertmacro MUI_SET MUI_HEADERIMAGE_UNBITMAP_RTL_NOSTRETCH ""
  70.           !endif
  71.         !endif
  72.       !endif
  73.  
  74.     !endif
  75.  
  76.     ;Default texts
  77.     !insertmacro MUI_DEFAULT MUI_ABORTWARNING_TEXT "$(MUI_TEXT_ABORTWARNING)"
  78.     !insertmacro MUI_DEFAULT MUI_UNABORTWARNING_TEXT "$(MUI_UNTEXT_ABORTWARNING)"  
  79.  
  80.     ;Apply settings
  81.  
  82.     XPStyle On ;XP style setting in manifest resource
  83.  
  84.     ;Dialog resources
  85.     ChangeUI all "${MUI_UI}" 
  86.     !ifdef MUI_HEADERIMAGE
  87.       !ifndef MUI_HEADERIMAGE_RIGHT
  88.         ChangeUI IDD_INST "${MUI_UI_HEADERIMAGE}"
  89.       !else
  90.         ChangeUI IDD_INST "${MUI_UI_HEADERIMAGE_RIGHT}"
  91.       !endif
  92.     !endif
  93.  
  94.     ;Icons
  95.     Icon "${MUI_ICON}"
  96.     UninstallIcon "${MUI_UNICON}"
  97.  
  98.   !endif
  99.  
  100. !macroend
  101.  
  102.  
  103. ;--------------------------------
  104. ;Abort warning message box
  105.  
  106. !macro MUI_ABORTWARNING
  107.  
  108.   !ifdef MUI_ABORTWARNING_CANCEL_DEFAULT
  109.     MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON2 "${MUI_ABORTWARNING_TEXT}" IDYES mui.Quit
  110.   !else
  111.     MessageBox MB_YESNO|MB_ICONEXCLAMATION "${MUI_ABORTWARNING_TEXT}" IDYES mui.Quit
  112.   !endif
  113.   
  114.   Abort
  115.   mui.Quit:
  116.  
  117. !macroend
  118.  
  119. !macro MUI_UNABORTWARNING
  120.  
  121.   !ifdef MUI_UNABORTWARNING_CANCEL_DEFAULT
  122.     MessageBox MB_YESNO|MB_ICONEXCLAMATION|MB_DEFBUTTON2 "${MUI_UNABORTWARNING_TEXT}" IDYES mui.Quit
  123.   !else
  124.     MessageBox MB_YESNO|MB_ICONEXCLAMATION "${MUI_UNABORTWARNING_TEXT}" IDYES mui.Quit
  125.   !endif
  126.  
  127.   Abort
  128.   mui.Quit:
  129.  
  130. !macroend
  131.  
  132.  
  133. ;--------------------------------
  134. ;Initialization of GUI
  135.  
  136. !macro MUI_HEADERIMAGE_INIT UNINSTALLER
  137.  
  138.   ;Load and display header image
  139.  
  140.   !ifdef MUI_HEADERIMAGE
  141.  
  142.     InitPluginsDir
  143.  
  144.     !ifdef MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_RTL
  145.  
  146.       ${if} $(^RTL) == 1
  147.  
  148.         File "/oname=$PLUGINSDIR\modern-header.bmp" "${MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_RTL}"
  149.  
  150.         !ifndef MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_RTL_NOSTRETCH
  151.           SetBrandingImage /IMGID=1046 /RESIZETOFIT "$PLUGINSDIR\modern-header.bmp"
  152.         !else
  153.           SetBrandingImage /IMGID=1046 "$PLUGINSDIR\modern-header.bmp"
  154.         !endif
  155.  
  156.       ${else}
  157.  
  158.     !endif
  159.  
  160.         File "/oname=$PLUGINSDIR\modern-header.bmp" "${MUI_HEADERIMAGE_${UNINSTALLER}BITMAP}"
  161.  
  162.         !ifndef MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_NOSTRETCH
  163.           SetBrandingImage /IMGID=1046 /RESIZETOFIT "$PLUGINSDIR\modern-header.bmp"
  164.         !else
  165.           SetBrandingImage /IMGID=1046 "$PLUGINSDIR\modern-header.bmp"
  166.         !endif
  167.  
  168.     !ifdef MUI_HEADERIMAGE_${UNINSTALLER}BITMAP_RTL
  169.  
  170.       ${endif}
  171.  
  172.     !endif
  173.  
  174.   !endif
  175.  
  176. !macroend
  177.  
  178. !macro MUI_GUIINIT_OUTERDIALOG UNINSTALLER
  179.  
  180.   ;Initialize outer dialog (fonts & colors)
  181.  
  182.   ;Header
  183.   GetDlgItem $mui.Header.Text $HWNDPARENT 1037
  184.   CreateFont $mui.Header.Text.Font "$(^Font)" "$(^FontSize)" "700"
  185.   SendMessage $mui.Header.Text ${WM_SETFONT} $mui.Header.Text.Font 0
  186.   
  187.   GetDlgItem $mui.Header.SubText $HWNDPARENT 1038
  188.  
  189.   !ifndef MUI_HEADER_TRANSPARENT_TEXT
  190.     SetCtlColors $mui.Header.Text "" "${MUI_BGCOLOR}"
  191.     SetCtlColors $mui.Header.SubText "" "${MUI_BGCOLOR}"
  192.   !else
  193.     SetCtlColors $mui.Header.Text "" "transparent"
  194.     SetCtlColors $mui.Header.SubText "" "transparent"
  195.   !endif
  196.   
  197.   ;Header image
  198.   !insertmacro MUI_HEADERIMAGE_INIT "${UNINSTALLER}"
  199.  
  200.   ;Header background
  201.   GetDlgItem $mui.Header.Background $HWNDPARENT 1034
  202.   SetCtlColors $mui.Header.Background "" "${MUI_BGCOLOR}"
  203.  
  204.   ;Header image background
  205.   GetDlgItem $mui.Header.Image $HWNDPARENT 1039
  206.   SetCtlColors $mui.Header.Image "" "${MUI_BGCOLOR}"
  207.  
  208.   ;Branding text
  209.   GetDlgItem $mui.Branding.Background $HWNDPARENT 1028
  210.   SetCtlColors $mui.Branding.Background /BRANDING
  211.   GetDlgItem $mui.Branding.Text $HWNDPARENT 1256
  212.   SetCtlColors $mui.Branding.Text /BRANDING
  213.   SendMessage $mui.Branding.Text ${WM_SETTEXT} 0 "STR:$(^Branding) "
  214.   
  215.   ;Lines
  216.   GetDlgItem $mui.Line.Standard $HWNDPARENT 1035
  217.   GetDlgItem $mui.Line.FullWindow $HWNDPARENT 1045
  218.   
  219.   ;Buttons
  220.   GetDlgItem $mui.Button.Next $HWNDPARENT 1
  221.   GetDlgItem $mui.Button.Cancel $HWNDPARENT 2
  222.   GetDlgItem $mui.Button.Back $HWNDPARENT 3
  223.  
  224. !macroend
  225.  
  226.  
  227. ;--------------------------------
  228. ;Interface functions
  229.  
  230. !macro MUI_FUNCTION_GUIINIT
  231.  
  232.   Function .onGUIInit
  233.  
  234.     !insertmacro MUI_GUIINIT_OUTERDIALOG ""
  235.  
  236.     !ifdef MUI_PAGE_FUNCTION_GUIINIT
  237.       Call "${MUI_PAGE_FUNCTION_GUIINIT}"
  238.     !endif  
  239.  
  240.     !ifdef MUI_CUSTOMFUNCTION_GUIINIT
  241.       Call "${MUI_CUSTOMFUNCTION_GUIINIT}"
  242.     !endif
  243.  
  244.   FunctionEnd
  245.  
  246. !macroend
  247.  
  248. !macro MUI_UNFUNCTION_GUIINIT
  249.  
  250.   Function un.onGUIInit  
  251.  
  252.     !insertmacro MUI_GUIINIT_OUTERDIALOG UN
  253.     
  254.     !ifdef MUI_UNPAGE_FUNCTION_GUIINIT
  255.       Call "${MUI_UNPAGE_FUNCTION_GUIINIT}"
  256.     !endif    
  257.  
  258.     !ifdef MUI_CUSTOMFUNCTION_UNGUIINIT
  259.       Call "${MUI_CUSTOMFUNCTION_UNGUIINIT}"
  260.     !endif
  261.  
  262.   FunctionEnd
  263.  
  264. !macroend
  265.  
  266. !macro MUI_FUNCTION_ABORTWARNING
  267.  
  268.   Function .onUserAbort
  269.   
  270.     !ifdef MUI_PAGE_FUNCTION_ABORTWARNING
  271.       Call ${MUI_PAGE_FUNCTION_ABORTWARNING}
  272.     !endif
  273.   
  274.     !ifdef MUI_ABORTWARNING
  275.       !insertmacro MUI_ABORTWARNING
  276.     !endif
  277.     
  278.     !ifdef MUI_CUSTOMFUNCTION_ABORT
  279.       Call "${MUI_CUSTOMFUNCTION_ABORT}"
  280.     !endif
  281.     
  282.   FunctionEnd
  283.  
  284. !macroend
  285.  
  286. !macro MUI_FUNCTION_UNABORTWARNING
  287.  
  288.   Function un.onUserAbort
  289.   
  290.     !ifdef MUI_UNPAGE_FUNCTION_ABORTWARNING
  291.       Call ${MUI_UNPAGE_FUNCTION_ABORTWARNING}
  292.     !endif  
  293.   
  294.     !ifdef MUI_UNABORTWARNING
  295.       !insertmacro MUI_UNABORTWARNING
  296.     !endif
  297.     
  298.     !ifdef MUI_CUSTOMFUNCTION_UNABORT
  299.       Call "${MUI_CUSTOMFUNCTION_UNABORT}"
  300.     !endif
  301.     
  302.   FunctionEnd
  303.  
  304. !macroend
  305.